﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class lop_bcsudungnhienlieu
    {
        string Mxe, Quangduong, MDM;
        int Xangtieuthu, Thangbc;
        public lop_bcsudungnhienlieu() { }
        public lop_bcsudungnhienlieu(string Mxe, string Quangduong, string MDM, int Xangtieuthu, int Thangbc)
        {
            this.Mxe = Mxe;
            this.Quangduong = Quangduong;
            this.MDM = MDM;
            this.Xangtieuthu = Xangtieuthu;
            this.Thangbc = Thangbc;
        }
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert into bcsudungnhienlieu values ('" + Mxe + "',N'" + Quangduong + "','" + MDM + "','" + Xangtieuthu + "','" + Thangbc + "')") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update bcsudungnhienlieu set Mxe='" + Mxe + "',Quangduong=N'" + Quangduong + "',Xangtieuthu='" + Xangtieuthu + "',Thangbc='" + Thangbc + "' where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from bcsudungnhienlieu where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
